﻿var rec = new Rectangle(3, 4);
Console.WriteLine("Rectangle's width:" + rec.Width);
Console.WriteLine("Rectangle's height:" + rec.GetHeight());
Console.WriteLine("Area is:" + rec.CalculateArea());

var person = new Person
{
    Name = "Jack",
    YearOfBirth = 1999
};


Console.ReadKey();


class Person
{
    public string Name { get; set; }
    public int YearOfBirth { get;init; }

    
}


class Rectangle
{
    public int Width;
    private int _height;
    private static DateTime _firstUsed;

    static Rectangle()
    {
        _firstUsed = DateTime.Now;
    }

    public Rectangle(int width, int height)
    {
        Width = GetLengthOrDefault(width, nameof(Width));
        _height = GetLengthOrDefault(height, nameof(_height));
    }

    public int GetHeight() => _height;

    public void SetHeight(int value)
    {
        if (value > 0)
        {
            _height = value;
        }
    }

    private int GetLengthOrDefault(int lenght, string name)
    {
        int defaultValueIfNonPositive = 1;
        if (lenght <= 0)
        {
            Console.WriteLine($"{name} must be a positive number.");
            return defaultValueIfNonPositive;
        }

        return lenght;
    }

    public int CalculateCircumference() => 2 * Width + 2 * _height;

    public int CalculateArea() => Width * _height;

    public string Description => $"A rectangle with width {Width}" + $"and height {_height}";
    
}

class Calculator
{
    public static int Add(int a, int b) => a + b;
    public static int Subtract(int a, int b) => a - b;
    
}